package com.nana.petadventure.ui.scene
{
	import com.nana.framework.ui.PSprite;
	import com.nana.petadventure.pe.PetEngine;
	
	import flash.events.Event;
	import flash.utils.Dictionary;
	
	public class BackgroundView extends PSprite
	{
		private var _bgDataDict:Dictionary;
		private var _bgSpriteList:Array;
		
		public function BackgroundView()
		{
			super();
		}
		
		public function reloadBg():void {
			this.removeAllChildren();
			for each (var bg:BackgroundSprite in _bgSpriteList) {
				bg.loadView();
				this.addChild(bg);
			}
			this.addEventListener(Event.ENTER_FRAME, onFrameMove);
		}
		
		private function onFrameMove(event:Event):void {
			this.moveAtSpeed(PetEngine.getInstance().observerSpeed);
		}
		
		public function moveAtSpeed(spd:int):void {
			for each (var bg:BackgroundSprite in _bgSpriteList) {
				bg.move(spd);
			}
		}
		
		public function pause():void {
			
		}
		
		public function resume():void {
			
		}

		public function get bgSpriteList():Array
		{
			return _bgSpriteList;
		}

		public function set bgSpriteList(value:Array):void
		{
			_bgSpriteList = value;
		}

	}
}